<template>
  <van-config-provider :theme-vars="themeTags">
    <div class="article-comment-container">
      <div class="left">
        <van-image round width="35" height="35" fit="cover" :src="commentInfo.avatarUrl" />
      </div>
      <div class="right">
        <div class="inner-section-1">
          <div class="name-box">
            <p class="name">
            <p style="margin-right: 5px;">{{ commentInfo.userName }}</p>
            <van-tag type="success" v-if="commentInfo.level <= 5">Lv.{{ commentInfo.level }}</van-tag>
            <van-tag type="primary" v-else-if="commentInfo.level <= 10">Lv.{{ commentInfo.level }}</van-tag>
            <van-tag type="warning" v-else-if="commentInfo.level <= 15">Lv.{{ commentInfo.level }}</van-tag>
            <van-tag type="danger" v-else>Lv.{{ commentInfo.level }}</van-tag>
            </p>
            <p class="time">{{ commentInfo.time }}</p>
          </div>
          <div class="thumb-box">
            <van-icon name="good-job" color="#c8c9cc" />
            <p class="like-number">{{ commentInfo.thumb }}</p>
          </div>
        </div>
        <p class="inner-section-2">
          {{ commentInfo.content }}
        </p>
        <div class="inner-section-3" v-if="commentInfo.subComment">
          <template v-for="item in commentInfo.subComment">
            <div class="sub-comment-item">
              <span class="sub-user">{{ item.respondentName }}：
                <span class="author-tag" v-if="item.respondentName === authorName">作者</span>
              </span>
              <span class="middle-text">回复 {{ item.repliedName }}<span class="author-tag"
                  v-if="item.repliedName === authorName">作者</span>：</span>
              <span class="content">{{ item.content }}</span>
            </div>
          </template>
        </div>
      </div>
    </div>
  </van-config-provider>
</template>

<script setup>
import { defineProps } from 'vue'

const props = defineProps({
  commentInfo: Object,
  authorName: String
})


// 重写tags样式
const themeTags = {
  tagPadding: '2px 5px',
  tagFontSize: '8px',
  tagLineHeight: '8px'
}
</script>

<style scoped>
.article-comment-container {
  position: relative;
  display: flex;
  align-items: flex-start;
  padding: 14px 0;
  font-size: 0;
  border-bottom: 1px solid #f2f3f5;
  background-color: #fff;
}

.article-comment-container .left {
  padding: 0 10px;
}
.article-comment-container .right {
  flex: 1;
  width: 0;
}

.article-comment-container .right .inner-section-1 {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.article-comment-container .right .inner-section-1 .name-box .name {
  display: flex;
  align-items: center;
}
.article-comment-container .right .inner-section-1 .name-box .name p {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #323233;
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
}
.article-comment-container .right .inner-section-1 .name-box .time {
  font-size: 12px;
  line-height: 16px;
  margin-top: 4px;
  color: #969799;
}
.article-comment-container .right .inner-section-1 .thumb-box {
  display: flex;
  align-items: baseline;
  font-size: 16px;
}
.article-comment-container .right .inner-section-1 .thumb-box .like-number {
  margin: 0 6px;
  font-size: 14px;
  line-height: 20px;
  color: #c8c9cc;
}

.article-comment-container .right .inner-section-2 {
  margin-top: 4px;
  font-size: 15px;
  line-height: 24px;
  color: #323233;
  vertical-align: center;
  word-break: break-all;
}

.article-comment-container .right .inner-section-3 {
  margin-top: 8px;
  padding: 10px;
  background: #f7f8fa;
}

.article-comment-container .right .inner-section-3 .sub-comment-item {
  margin-top: 2px;
  font-size: 13px;
  line-height: 19px;
  color: #323233;
}
.article-comment-container .right .inner-section-3 .sub-comment-item .sub-user {
  display: inline-flex;
  align-items: center;
  height: 19px;
  white-space: nowrap;
  color: #004b96;
}

.middle-text {
  color: #969799;
}

.author-tag {
  padding: 0 3px;
  margin-left: 4px;
  border-radius: 2px;
  font-size: 10px;
  line-height: 12px;
  color: #fff;
  background: #14191e;
}
</style>
